package com.zhiyou100.api.book_demo.test;

import com.zhiyou100.api.book_demo.dao.BookInfoDao;
import com.zhiyou100.api.book_demo.dao.CategoryDao;
import com.zhiyou100.api.book_demo.dao.impl.BookInfoDaoImpl;
import com.zhiyou100.api.book_demo.dao.impl.CategoryDaoImpl;
import com.zhiyou100.api.book_demo.pojo.BookInfo;
import com.zhiyou100.api.book_demo.pojo.Category;

import java.time.LocalDate;
import java.util.List;

public class Main {

    public static void main(String[] args) {

        CategoryDao categoryDao = new CategoryDaoImpl();
        //查询所有类别
        List<Category> list = categoryDao.queryAll();
        System.out.println(list);
        //添加新的类别
        Category category = new Category("1004", "哲学类");
        boolean b = categoryDao.insertCategory(category);
        System.out.println(b);
        System.out.println("---------重新查询所有类别----------------");
        List<Category> list2 = categoryDao.queryAll();
        System.out.println(list2);
        System.out.println("------------重复添加-------------");
        Category category2 = new Category("1004", "哲学类");
        boolean b2 = categoryDao.insertCategory(category2);
        System.out.println(b2);
        List<Category> list3 = categoryDao.queryAll();
        System.out.println(list3);
        System.out.println("--------------修改--------------");
        category2 = new Category("1004", "社会类");
        boolean result = categoryDao.editCategoryById(category2);
        System.out.println(result);
        list3 = categoryDao.queryAll();
        System.out.println(list3);
        System.out.println("----------获取所有图书-----------");
        BookInfoDao bookInfoDao = new BookInfoDaoImpl();
        List<BookInfo> bookInfos = bookInfoDao.queryAll();
        System.out.println(bookInfos);
        System.out.println("-*********--根据图书类别查找图书------------");
        List<BookInfo> list1 = bookInfoDao.queryInfoByCategory(new Category("1004", "社会类"));
        System.out.println(list1);
        System.out.println("------------添加------------");
        bookInfoDao.insertBookInfo(new Category("1004", "社会类"),new BookInfo("100401","社会学说",56,"张三", LocalDate.now()));
        System.out.println(bookInfoDao.queryAll());
    }

}
